<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="yes" />
<title>信呼</title>
<link rel="stylesheet" type="text/css" href="res/css/webimcss.css"/>
<link rel="shortcut icon" href="favicon.ico" />
<script type="text/javascript" src="res/js/jquery.js"></script>
<script type="text/javascript" src="res/js/js.js"></script>
<script type="text/javascript" src="res/js/base64-min.js"></script>
<script type="text/javascript" src="res/js/nwjs.js"></script>
<style>
.lmaisft{width:380px;border-radius:10px;text-align:left; background-color:#C4E0F4;background: rgba(255,255,255,0.5);box-shadow:0px 0px 10px rgba(0,0,0,0)}
</style>
<script>
var temp_token='';
function initbody(){
	resize();
	$(window).resize(resize);
	js.splittime=0;
	var us=js.request('user',js.getoption('adminuser')),murl=js.request('murl');
	temp_token=js.request('token');
	if(murl){
		murl=jm.base64decode(murl);
		js.setoption('apiurl', murl);
		apiurl=murl;
	}
	$('#adminuser').val(us);
	var face = js.getoption('adminface');
	if(face)get('myface').src=face;
	nwjs.init();
	nwjs.createtray('信呼', 0);
	if(temp_token.length>=8&&us!=''){
		loginsubmit(0);
	}
}
function bodyunload(){
	nwjs.removetray();
}
function resize(){
	var tt=$(window).height()-$('.lmaisft').height();
	var ts=(tt*0.5)-5;
	if(ts<10)ts=10;
	$('#topblank').css('height',''+ts+'px');
}
function loginsubmit(lx){
	if(js.ajaxbool)return false;
	var user = get('adminuser').value;
	var pass = get('adminpass').value;
	if(lx==1)temp_token='';
	js.setmsg('');
	if(user==''){
		js.setmsg('用户名不能为空');
		get('adminpass').focus();
		return false;
	}
	if(pass==''&&temp_token==''){
		js.setmsg('密码不能为空');
		get('adminpass').focus();
		return false;
	}
	var o = get('btn0');
	o.value='登录中...';
	o.disabled=true;
	js.setoption('adminuser', user);
	js.setmsg('');
	js.ajax('login','check',{user:jm.base64encode(user),pass:jm.base64encode(pass),token:temp_token}, function(da){
		o.value='登录成功';
		loginsuccess(da);
	},'none',false, function(str){
		o.value='登录';
		o.disabled=false;
	});
	return false;
}
function loginsuccess(a){
	js.setoption('adminid',a.uid);
	js.setoption('adminname',a.name);
	js.setoption('adminuser',a.user);
	js.setoption('adminface',a.face);
	js.setoption('admintoken',a.token);
	if(nwjsgui){
		js.location('mainnw.html?rnd='+js.getrand()+'');
	}else{
		js.location('main.html?rnd='+js.getrand()+'');
	}
}
function loginset(){
	js.prompt('设置', '您系统地址', function(lx,url){
		if(lx!='yes'||!url)return;
		if(url.substr(url.length-1,1)!='/')url=url+'/';
		js.setoption('apiurl', url);
		apiurl=url;
		js.msg('success','设置成功');
	}, apiurl);
}
</script>
</head>


<body style="background:#66A8E5 url(images/loginbg.jpg) top center no-repeat">
<div align="center">

	<div style="height:50px;overflow:hidden" id="topblank"></div>

	<div class="lmaisft">
		<div class="blank20"></div>
		<div class="ltoplog" align="center"><img onclick="location.reload()" src="images/logo.png" id="myface" align="absmiddle"  height="60" width="60"></div>
		
		<form style="padding:20px;padding-left:60px" name="myform">
			
			<div>
				<div><input type="text" style="height:35px;width:250px" class="input" onKeyUp="if(event.keyCode==13)get('adminpass').focus()" maxlength="20" placeholder="请输入用户名" id="adminuser" name="adminuser" ></div>
			</div>

			<div class="blank20"></div>
			<div>
				<div><input  style="height:35px;width:250px" class="input"  onKeyUp="if(event.keyCode==13)loginsubmit(1)" value=""  name="adminpass" id="adminpass" type="password" placeholder="请输入密码"></div>
			</div>
			
			<div class="blank10"></div>
			<div>
				<span style="color:#888888;font-size:12px">&nbsp;没有帐号?请联系管理员 &nbsp;<a onclick="return loginset()" href="javascript:">[设置]</a> &nbsp;查看<a target="_blank" href="http://xh829.com/help.html">[帮助?]</a></span>
			</div>
			
			<div class="blank20"></div>

			<div align="left">
				<input type="button" id="btn0" onClick="loginsubmit(1)" class="btn" value="登录">&nbsp;<span id="msgview"></span>
			</div>

		</form>
	
	</div>

</div>
</body>
</html>